<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="/static/js/head.js"></script>
<link rel="stylesheet" type="text/css" href="/static/css/contractList.css" />
</head> 
<body id="layout" class="easyui-layout">
	<div data-options="region:'center',border:false">
		<table id="infoDrid"></table>
	</div>
	<input type="hidden" id="contractId">
	<!-- dataGrid工具栏 -->
	<div id="toolbar">
		<a id="updateFinance" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ccEdit',plain:true" >更新财务信息</a>
		<a id="uploadBTN" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ccOut',plain:true" >上传文件</a>
		<a id="checkFile" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-accolist',plain:true" >查看附件</a>
		<a id="createContractOrder" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ccAdd',plain:true" >创建订单</a>
		<a id="edit" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ccEdit',plain:true" >编辑订单</a>
		<a id="finish" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-lock',plain:true" >结束订单</a>
		<a id="delete" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" >删除订单</a>
		<!-- <a id="search" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ccSearch',plain:true" >查询</a> -->
	</div>
	<!-- 添加合同订单 -->
	<div id="addDialog">
		<form id="addForm">
			<table class="tableForm">
				<tr>
					<td class="formLeft">MISS编号:</td>
					<td>
						<input class="easyui-validatebox" data-options="validType:'positionCodes',required:true" name="missNo" id="missNo">
						<input id="orderId" value="0" type="hidden">
					</td>
				</tr>
				<tr>
					<td class="formLeft">税率(%):</td>
					<td id="updateRoleTD">
					<input class="easyui-numberbox" data-options="validType:'positionCodes',required:true,min:0" name="taxRate" id="taxRate" precision="2">
					</td>
				</tr>
				<tr>
					<td class="formLeft">订单编号:</td>
					<td>
						<input class="easyui-validatebox" data-options="validType:'positionCodes',required:true" name="orderNo" id="orderNo">
					</td>
				</tr>
				<tr>
					<td class="formLeft">订单名称:</td>
					<td>
						<input class="easyui-validatebox" data-options="validType:'positionCodes',required:true" name="orderName" id="orderName">
					</td>
				</tr>
				<tr>
					<td class="formLeft">大项编号:</td>
					<td>
						<input class="easyui-validatebox"  data-options="required:true" name="bigItemNo" id="bigItemNo">
					</td>
				</tr>
				<tr>
					<td class="formLeft">订单金额:</td>
					<td>
						<input class="easyui-numberbox" data-options="required:true,min:0" name="orderAmount" id="orderAmount" precision="2">
					</td>
				</tr>
				<tr>
					<td class="formLeft">开始时间:</td>
					<td>
						<input class="easyui-datebox"  data-options="required:true" name="startTime" id="startTime">
					</td>
				</tr>
			</table>
		</form>
	</div>
	<div id="updateDialog">
		<form id="updateForm">
			<table class="tableForm">
				
				<tr>
					<td class="formLeft" style="width:auto;">大项开票金额:</td>
					<td>
						<input class="easyui-numberbox" data-options="validType:'positionCodes',required:true,min:0" name="invoiceAmount" id="invoiceAmount" precision="2">
					</td>
				</tr>
				
				<tr id="stateRow" >
					<td class="formLeft">回款金额1:</td>
					<td>
						<input class="easyui-numberbox" data-options="min:0" name="amount1" id="amount1" precision="2">
					</td>
				</tr>
				<tr id="stateRow" >
					<td class="formLeft">回款时间1:</td>
					<td>
						<input class="easyui-datebox" name="paidTime1" id="paidTime1">
					</td>
				</tr>
				<tr id="stateRow" >
					<td class="formLeft">回款金额2:</td>
					<td>
						<input class="easyui-numberbox" data-options="min:0" name="amount2" id="amount2" precision="2">
					</td>
				</tr>
				<tr id="stateRow" >
					<td class="formLeft">回款时间2:</td>
					<td>
						<input class="easyui-datebox" name="paidTime2" id="paidTime2">
					</td>
				</tr>
				<tr id="stateRow" >
					<td class="formLeft">回款金额3:</td>
					<td>
						<input class="easyui-numberbox" data-options="min:0" name="amount3" id="amount3" precision="2">
					</td>
				</tr>
				<tr id="stateRow" >
					<td class="formLeft">回款时间3:</td>
					<td>
						<input class="easyui-datebox" name="paidTime3" id="paidTime3">
					</td>
				</tr>
			</table>
		</form>
	</div>
	<div id="editDialog">
		<form id="editForm">
			<table class="tableForm">
				<tr>
					<td class="formLeft">MISS编号:</td>
					<td>
						<input class="easyui-validatebox" data-options="validType:'positionCodes',required:true" name="updateMissNo" id="updateMissNo">
						<input id="orderId" value="0" type="hidden">
					</td>
				</tr>
				<tr>
					<td class="formLeft">税率(%):</td>
					<td id="updateRoleTD">
					<input class="easyui-numberbox" data-options="validType:'positionCodes',required:true,min:0" name="updateTaxRate" id="updateTaxRate" precision="2">
					</td>
				</tr>
				<tr>
					<td class="formLeft">订单编号:</td>
					<td>
						<input class="easyui-validatebox" data-options="required:true" name="updateOrderNo" id="updateOrderNo">
						<input id="orderID" value="0" type="hidden">
					</td>
				</tr>
				<tr>
					<td class="formLeft">订单名称:</td>
					<td>
						<input class="easyui-validatebox" data-options="required:true" name="updateOrderName" id="updateOrderName">
					</td>
				</tr>
				<tr>
					<td class="formLeft">大项编号:</td>
					<td id="updateRoleTD">
					<input class="easyui-validatebox" data-options="required:true" name="updateBigItemNo" id="updateBigItemNo">
					</td>
				</tr>
				<tr id="stateRow" >
					<td class="formLeft">订单金额:</td>
					<td>
						<input class="easyui-numberbox" data-options="required:true,min:0" name="updateOrderAmount" id="updateOrderAmount">
					</td>
				</tr>
				<tr id="stateRow" >
					<td class="formLeft">开始时间:</td>
					<td>
						<input class="easyui-datebox" data-options="required:true" name="updateStartTime" id="updateStartTime">
					</td>
				</tr>
			</table>
		</form>
	</div>
	<!-- 上传 -->
	<div id="uploadDialog">
		<form id="uploadForm" enctype="multipart/form-data" method="post" accept-charset="UTF-8" >
			<table class="tableForm">
				<tr>
					<td><label>上传类型</label></td>
					<td>
						<label><input type="radio" name="certType" checked="checked" value="1">发票文件</label>
			            <label><input type="radio" name="certType" value="2">订单文件</label>
					</td>
				</tr>
				<tr id="inputCB1" >
					<td><label>选择文件</label></td>
					<td>
						<input id="miData" type="text">
						<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-upload',plain:true"
							onClick="document.getElementById('file').click()"></a>
						<input type="file" style="width:300px" id="file" name="file" class="filePrew"
						 onchange="change_photo();" multiple="multiple">
			            <input type="text" id="uploadOrderID" style="display: none;">
					</td>
				</tr>
				<tr id="inputCB4" >
					<td ><label>图片预览</label></td>
					<td>
						<div id="Imgdiv">
						</div>
					</td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>

<script>
	$(function(){
		$.ajaxSetup({crossDomain: true, xhrFields: {withCredentials: true}});
		$("#contractId").val(sessionStorage.getItem('contractId'));
		//页面初始化
		layoutLoad();
		//数据表格加载
		gridLoad(1,15);	
		//loadAndSetGridData();	
		//点击事件
		clickFunction();
	});
	//页面初始化
	function layoutLoad(){
//		$('#layout').layout('collapse','east');
		//信息添加dialog
		$('#addDialog').dialog({
			title: '添加合同订单',
		    width: 300,
		    height:400,
		    closed: true,    
		    modal: true,
		    buttons:[{
				text:'确定',
				iconCls:'icon-ok',
				handler:function(){
					addInfo();//添加信息
                }
			},{
				text:'取消',
				iconCls:'icon-cancel',
				handler:function(){
					$('#addDialog').dialog('close');
				}
			}], 
		});
		$('#updateDialog').dialog({
			title: '更新财务信息',
		    width: 400,
		    height:400,
		    closed: true,
		    modal: true,
		    buttons:[{
				text:'确定',
				iconCls:'icon-ok',
				handler:function(){
					updatedInfo();//添加信息
                }
			},{
				text:'取消',
				iconCls:'icon-cancel',
				handler:function(){
					$('#updateDialog').dialog('close');
				}
			}], 
		});
		$('#editDialog').dialog({
			title: '编辑订单',
		    width: 300,
		    height:400,
		    closed: true,
		    modal: true,
		    buttons:[{
				text:'确定',
				iconCls:'icon-ok',
				handler:function(){
					editInfo();//添加信息
                }
			},{
				text:'取消',
				iconCls:'icon-cancel',
				handler:function(){
					$('#editDialog').dialog('close');
				}
			}], 
		});
		//上传dialog
		$('#uploadForm').dialog({
			title: '上传',
		    width: 500,
		    height:500,
		    closed: true,    
		    modal: true,
		    buttons:[{
				text:'确定',
				iconCls:'icon-ok',
				handler:function(){
					uploadFiles()
                }
			},{
				text:'取消',
				iconCls:'icon-cancel',
				handler:function(){
					$('#uploadForm').dialog('close');
				}
			}], 
		});
	}
	//数据表格加载
	function gridLoad(pageNumber,pageSize) {
		$.ajax({
			url : getHost() + '/contract_order/list/pageable/adapter/order_by_create_time_desc',
			type : "GET",
			data : {
				"pageNumber": pageNumber,
			    "pageSize": pageSize,
			    "contractId" : $("#contractId").val()
			},
			async : false,
			dataType : "json",
			contentType: 'application/json;charset=UTF-8',
			success : function(data) {
				if (data.code==200&&typeof(data.data) == "object") {
					var width = $('#infoDrid').parent().width();
					var height = $('#infoDrid').parent().height();
					$('#infoDrid').datagrid({
						toolbar : "#toolbar",
						data: data.data.page.rows,
						width : 1380,
						height : height,
						async : false,
						fit : true,
						border : false,
						singleSelect : true,
						fitColumns : true,
						striped : true,
						pagination : true,
						scrollbarSize:0 ,
						columns : [ [
							{field:'orderNo',title:'订单编号' ,align:'center', },
							{field:'orderName',title:'订单名称',align:'center' },
							{field:'bigItemNo',title:'大项编号',align:'center' },
							{field:'orderAmount',title:'订单金额',align:'center' },
							{field:'missNo',title:'MISS编号',align:'center' },
							{field:'invoiceAmount',title:'大项开票金额',align:'center' },
							{field:'taxRate',title:'税率',align:'center' ,formatter: function(value,row,index){
								if(value>=0){
									return value+"%";
								}else{
									return value;
								}
							}},
							{field:'amountCashed',title:'回款金额',align:'center' },
							{field:'amountCashedPercent',title:'回款比例',align:'center' },
							{field:'amountBalance',title:'尾款金额',align:'center' },
							{field:'startTime',title:'开始时间',align:'center' },
							{field:'status',title:'订单状态',align:'center' ,
								formatter: function(value,row,index){
									if(value=="2"){
										return "已结束";
									}else if(value=="1"){
										return "未结束";
									}else{
										return "";
									}
								}
							},
							{field:'endTime',title:'结束时间',align:'center' },
							{field:'id',title:'操作',align:'center' ,
								formatter: function(value,row,index){
									return "<input style=\"cursor:pointer;\" type=\"button\" value=\"小项列表\" onClick=\"smallItemList(" + index + ")\" style=\"width:100px\"/>";
								}
							},
						] ],
					});
						var p = $('#infoDrid').datagrid('getPager');
				        $(p).pagination({
				        	total : data.data.page.total,
				            pageSize: pageSize,
				            pageList: [15, 30, 50],
				            pageNumber : pageNumber,
				            beforePageText: '第',
				            afterPageText: '页    共 {pages} 页',
				            displayMsg: '当前显示 {from}-{to} 条记录,共 {total} 条记录',
				            showRefresh : false,
				            onSelectPage:function(pageNumber, pageSize){
				        		gridLoad(pageNumber,pageSize);
				        	}
				        });
				}else{
					$.messager.alert("提示",data.message);
				}
			}
		});
	}
	//点击事件
	function clickFunction() {
		$('#search').click(function() {
			$('#layout').layout('expand', 'east');
		});
		//点击查询
		$('#searchbtn').click(function() {
			gridLoad(1,15);
		});
		$('#resetbtn').click(function() {
			$('#searchForm')[0].reset();
			$("#loginnameSearch").val('');
			$("#signdate").val('');
			$('#stattimeSearch').datetimebox('setValue', '');
			$('#endtimeSearch').datetimebox('setValue', '');
			gridLoad(1,15);
		});
		$('#createContractOrder').click(function(){
			$('#addForm')[0].reset();
			$('#addDialog').dialog('open');
		});
		//更新财务信息
		$('#updateFinance').click(function() {
			var row = $('#infoDrid').datagrid('getSelected');
			if(row==null){
				$.messager.alert("提示","请选中一行!");
				return;
			}
			$('#updateForm')[0].reset();
			$("#paidTime1").datebox("setValue",""); 
			$("#paidTime2").datebox("setValue",""); 
			$("#paidTime3").datebox("setValue",""); 
			$("#orderId").val(row.id);
			$('#updateForm').form('load',row);
			$('#updateDialog').dialog('open');
		});
		
		//编辑点击事件
		$('#edit').click(function() {
			var row = $('#infoDrid').datagrid('getSelected');
			if(row==null){
				$.messager.alert("提示","请选中一行!");
				return;
			}
			$('#editForm')[0].reset();
			$("#orderID").val(row.id);
			$("#updateMissNo").val(row.missNo).validatebox('validate');
			$('#updateTaxRate').numberbox('setValue', row.taxRate);
			$("#updateOrderNo").val(row.orderNo).validatebox('validate');
			$("#updateOrderName").val(row.orderName).validatebox('validate');
			$("#updateBigItemNo").val(row.bigItemNo).validatebox('validate');
			$('#updateOrderAmount').numberbox('setValue', row.orderAmount);
			$('#updateStartTime').datebox('setValue', row.startTime);
			$('#editDialog').dialog('open');
		});
		//删除 
		$('#delete').click(function() {
			var row = $('#infoDrid').datagrid('getSelected');
			if(row==null){
				$.messager.alert("提示","请选中一行!");
				return;
			}
			$.messager.confirm('提示','确定要删除该订单吗?<br/>'+row.orderName,function(r){
			    if (r){
			    	$.ajax({
						url:getHost() + '/contract_order/' + row.id,
						type:'DELETE',
						error:function(){
							$.messager.alert("提示","数据操作存在异常!");
						},
						contentType: 'application/json;charset=UTF-8',
						success:function(data){
							if(data.code==200){
								$.messager.alert("提示","删除成功");
								gridLoad(1,15);
							}else{
								$.messager.alert("提示",data.message);
							}
						}
					});
			    }
			});
		});
		//结束订单
		$('#finish').click(function() {
			var row = $('#infoDrid').datagrid('getSelected');
			if(row==null){
				$.messager.alert("提示","请选中一行!");
				return;
			}
			$.messager.confirm('提示','确定要结束吗?',function(r){
			    if (r){
			    	$.ajax({
						url:getHost() + '/contract_order/end?contractOrderId=' + row.id,
						type:'GET',
						error:function(){
							$.messager.alert("提示","数据操作存在异常!");
						},
						contentType: 'application/json;charset=UTF-8',
						success:function(data){
							if(data.code=200&&typeof(data.data) == "object"&&data.data.item.id>0){
								var mssalet = $.messager.alert("提示","操作成功");
								mssalet.window({modal:true,onBeforeClose:function() {
									gridLoad(1,15);
								}});
							}else{
								var mssalet = $.messager.alert("提示",data.message);
								mssalet.window({modal:true,onBeforeClose:function() {
									gridLoad(1,15);
								}});
							}
						}
					});
			    }
			});
		});
		//上传 
		$('#uploadBTN').click(function() {
			var row = $('#infoDrid').datagrid('getSelected');
			if(row==null){
				$.messager.alert("提示","请选中一行!");
				return;
			}
			$('#uploadForm')[0].reset();
			$("#uploadOrderID").val(row.id);
			$('#uploadForm').dialog('open');
		});
		//查看附件
		$('#checkFile').click(function() {
			var row = $('#infoDrid').datagrid('getSelected');
			if(row==null){
				$.messager.alert("提示","请选中一行!");
				return;
			}
			sessionStorage.setItem('fileType','2');
			sessionStorage.setItem('row',JSON.stringify(row));
			parent.addTab('附件展示',  "/accessories.html");
		});
	}
	//添加信息
	function addInfo(){
		if($("#missNo").val()==null ||$("#missNo").val()==""){
			$.messager.alert("提示","MISS编号不能为空!");
			return;
		}
		if($("#taxRate").val()==null ||$("#taxRate").val()==""||$("#taxRate").val()==0){
			$.messager.alert("提示","税率不能为空!");
			return;
		}
		if($("#orderNo").val()==null ||$("#orderNo").val()==""){
			$.messager.alert("提示","订单编号不能为空!");
			return;
		}
		if($("#orderName").val()==null ||$("#nickname").val()==""){
			$.messager.alert("提示","订单名称不能为空!");
			return;
		}
		if($("#bigItemNo").val()==null ||$("#bigItemNo").val()==""){
			$.messager.alert("提示","大项编号不能为空!");
			return;
		}
		if($("#orderAmount").val()==null ||$("#orderAmount").val()==""){
			$.messager.alert("提示","订单金额不能为空!");
			return;
		}
		$.ajax({
			url:getHost() + '/contract_order',
			type:'POST',
			data:JSON.stringify({
				missNo: $("#missNo").val(),
			    taxRate: $("#taxRate").val(),
				orderNo : $("#orderNo").val(),
				orderName : $("#orderName").val(),
				bigItemNo : $("#bigItemNo").val(),
				orderAmount : $("#orderAmount").val(),
				contractId : $("#contractId").val(),
				startTime : $("#startTime").val(),
			}),
			contentType: 'application/json;charset=UTF-8',
			beforeSend: function(xhr) {
                xhr.withCredentials = true;
            },
            crossDomain:true,
			error:function(){
				$.messager.alert("提示","数据操作存在异常!");
				$('#addDialog').dialog('close');
			},
			success:function(data){
				if(data.code==200&&typeof(data.data) == "object"&&typeof(data.data.item) == "object"&&data.data.item.id>0){
					$.messager.alert("提示","创建成功");
					$('#addForm').form('clear');
					$('#addDialog').dialog('close');
					$('#infoDrid').datagrid('load');
					gridLoad(1,15);
				}else{
					$.messager.alert("提示",data.message);
				}
			}
		});
	}
	//更新财务信息 
	function updatedInfo(){
		$.ajax({
			url:getHost() + '/contract_order/update_finance_item',
			type:'PUT',
			data:JSON.stringify({
				"id": $("#orderId").val(),
			    "invoiceAmount": $("#invoiceAmount").val(),
			    "amount1": $("#amount1").val(),
			    "paidTime1": $("#paidTime1").val(),
			    "amount2": $("#amount2").val(),
			    "paidTime2": $("#paidTime2").val(),
			    "amount3": $("#amount3").val(),
			    "paidTime3": $("#paidTime3").val(),
			}),
			contentType: 'application/json;charset=UTF-8',
			beforeSend: function(xhr) {
                xhr.withCredentials = true;
            },
            crossDomain:true,
			error:function(){
				$.messager.alert("提示","数据操作存在异常!");
				$('#addDialog').dialog('close');
			},
			success:function(data){
				if(data.code==200&&typeof(data.data) == "object"&&typeof(data.data.item) == "object"&&data.data.item.id>0){
					$.messager.alert("提示","修改成功");
					$('#updateForm').form('clear');
					$('#updateDialog').dialog('close');
					//$('#infoDrid').datagrid('load');
					gridLoad(1,15);
				}else{
					$.messager.alert("提示",data.message);
				}
			}
		});
	}
	//修改信息
	function editInfo(){
		if($("#editForm").form('validate')){
			var row = $('#infoDrid').datagrid('getSelected');
			var invoiceAttachmentList = JSON.parse(getID(JSON.stringify(row.invoiceAttachmentList)));
			$.ajax({
				url:getHost() + '/contract_order',
				type:'PUT',
				data:JSON.stringify({
					missNo: $("#updateMissNo").val(),
				    taxRate: $("#updateTaxRate").val(),
					orderNo : $("#updateOrderNo").val(),
					orderName : $("#updateOrderName").val(),
					bigItemNo : $("#updateBigItemNo").val(),
					orderAmount : $("#updateOrderAmount").val(),
					contractId : $("#contractId").val(),
					startTime : $("#updateStartTime").val(),
					id : $("#orderID").val(),
					invoiceAttachmentList : invoiceAttachmentList,
				}),
				dataType : "json",
				contentType: 'application/json;charset=UTF-8',
				error : function(XMLHttpRequest, textStatus, errorThrown){
					$.messager.alert("提示","数据操作存在异常!");
				},
				beforeSend: function(xhr) {
	                xhr.withCredentials = true;
	            },
	            crossDomain:true,
				success:function(data){
					if(data.code=="200"&&data.data.item.id>0){
						$.messager.alert("提示","保存成功");
						$('#editForm').form('clear');
						$('#editDialog').dialog('close');
						gridLoad(1,15);
					}else{
						$.messager.alert("提示",data.message);
					}
				}
			});
		}
	}
	//查看合同订单列表 
	function smallItemList(index) {
		var rows = $('#infoDrid').datagrid('getRows');//获得所有行
        var row = rows[index];//根据index获得其中一行。
		sessionStorage.setItem('orderId',row.id);
		sessionStorage.setItem('orderName',row.orderName);
		parent.addTab('小项列表',  "/smallItemList.html");
	};
	//上传
	function uploadFiles(){
 	    var count = 0;
	    var ids = "";
    	var files = document.getElementById("file").files;
    	var fl = files.length;
		for(var i=0; i< fl; i++){
			var fileObj = document.getElementById("file").files[i];
			var formFile = new FormData();
            formFile.append("file", fileObj); //加入文件对象
			$.ajax({
				url:getHost() + '/file',
				type : 'post',
                data: formFile,
				error : function(data) {
					$.messager.alert('提示', "第"+i+"张"+'上传失败！');
				},
				contentType : false,
				processData : false,
				async : false,
				success : function(data) {
					if(data.code=="200"&&data.data.item.id>0){
						ids += data.data.item.id + ",";
						count+=1;
					}else{
						$.messager.alert("提示","第"+i+"张"+data.message);
					}
				}
			});
		}
		if(count==fl){
			var row = $('#infoDrid').datagrid('getSelected');
			var invoiceAttachmentList = "",orderImageAttachmentList = "";
			var invoiceAttachmentList = JSON.parse("["+ids.substring(0,ids.length-1)+"]");
			if($("input[name='certType']:checked").val()==1){
				invoiceAttachmentList = JSON.parse("["+ids.substring(0,ids.length-1)+"]");
				orderImageAttachmentList = JSON.parse(getID(JSON.stringify(row.orderImageAttachmentList)));
			}else if($("input[name='certType']:checked").val()==2){
				orderImageAttachmentList = JSON.parse("["+ids.substring(0,ids.length-1)+"]");
				invoiceAttachmentList = JSON.parse(getID(JSON.stringify(row.invoiceAttachmentList)));
			}
			$.ajax({
				url:getHost() + '/contract_order',
				type:'PUT',
				data:JSON.stringify({
					missNo: row.missNo,
				    taxRate: row.taxRate,
					orderNo : row.orderNo,
					orderName : row.orderName,
					bigItemNo : row.bigItemNo,
					orderAmount : row.orderAmount,
					id : row.id,
					startTime : row.startTime,
					invoiceAttachmentList : invoiceAttachmentList,
					orderImageAttachmentList : orderImageAttachmentList,
				}),
				dataType : "json",
				contentType: 'application/json;charset=UTF-8',
				error : function(XMLHttpRequest, textStatus, errorThrown){
					$.messager.alert("提示","数据操作存在异常!");
				},
				beforeSend: function(xhr) {
	                xhr.withCredentials = true;
	            },
	            crossDomain:true,
				success:function(data){
					if(data.code=="200"&&data.data.item.id>0){
						$.messager.alert("提示","上传成功");
						$('#uploadForm').form('clear');
						$("#Imgdiv").html("");
						gridLoad(1,15);
						$('#uploadForm').dialog('close');
					}else{
						$.messager.alert("提示",data.message);
					}
				}
			});
		}
	}
	function change_photo(){
		$("#Imgdiv").html("");
		var files = document.getElementById("file").files;
		var names = "";
		for(var i=0; i< files.length; i++){
			names += files[i].name+",";
		}
		//alert(names);
		$("#miData").val(names.substring(0,names.length));
	    PreviewImage($("input[id='file']")[0]);
	}
	function PreviewImage(fileObj){
	    var allowExtention=".jpg,.bmp,.gif,.png,.pdf,.jpeg,.zip,.rar";//允许上传文件的后缀名document.getElementById("hfAllowPicSuffix").value;  
	    var browserVersion= window.navigator.userAgent.toUpperCase();
	    //循环判断后缀名
	    for(i=0;i<fileObj.files.length;i++){
	    	var extention=fileObj.files[i].name.substring(fileObj.files[i].name.lastIndexOf("."),fileObj.files[i].name.length).toLowerCase();
	    	if(allowExtention.indexOf(extention)<0){
	    		$.messager.alert("仅支持"+allowExtention+"为后缀名的文件!");  
	   	        fileObj.value="";//清空选中文件  
	   	        if(browserVersion.indexOf("MSIE")>-1){
	   	            fileObj.select();  
	   	            document.selection.clear();  
	   	        }                  
	   	        fileObj.outerHTML=fileObj.outerHTML;
	   	        return false;
	    	}
	    }
	    
	    $.each(fileObj.files,function(key,value){
	        //每次都只会遍历一个图片数据
	        var div = document.createElement("div");
	        var img = document.createElement("img");
	        div.className = "pic";
	        img.width="200";
	        img.height="200";

	        var fr = new FileReader();
	        fr.onload = function(){
	        	if(this.result.substring(5,this.result.indexOf("/"))=="image"){
		            img.src=this.result;
	        	}else{
	        		img.src="/static/images/compress.jpg";
	        	}
	            div.appendChild(img);
	            document.getElementById("Imgdiv").appendChild(div);
	        }
	        fr.readAsDataURL(value);
	    })
	}
	function getID(con){
		con = JSON.parse(con);
		var str = "";
		for(i=0;i<con.length;i++){
			str += con[i].id + ",";
		}
		return "["+str.substring(0,str.length-1)+"]";
	}
</script>